"""author: wenyao
   data: 2021/12/14
   project: cjh
"""
#健壮性
# import math
# math.sin(60)
#
# #python自省
# print(hasattr(math, "xx")) #判断math有没有xx属性
# print(setattr(math,"xx",1)) #设置math的xx属性为1
# print(getattr(math,"xx"))  #获取math的xx属性
# print(delattr(math,"xx"))  #删除math的xx属性

class A:
    name = "sc"
    __max = "max"

    def func1(self):
        print("i am func1")
a = A()
print(hasattr(a, "name"))
if hasattr(a, "name"):
    print(getattr(a, "name"))
if hasattr(a, "func1"):
    result = getattr(a, "func1")
    result()

def func2():
    print("i am func2")
setattr(a, "func2", func2)
a.func2()